package com.woniuxy.user.service.impl;

import com.woniuxy.entity.User;
import com.woniuxy.user.mapper.UserMapper;
import com.woniuxy.user.service.UserService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class UserServiceImpl implements UserService {
    @Resource
    UserMapper userMapper;

    @Override
    public List<User> getAllUsers() {
        List<User> users = userMapper.selectAll();
        return users;
    }

    @Override
    public User getUser(int id) {
        User user = userMapper.selectById(id);
        return user;
    }

    @Override
    public User getUserByName(String username) {
        User user = userMapper.selectByName(username);
        return user;
    }

    @Override
    public List<User> getName(String username) {
        return userMapper.selectName(username);
    }

    @Override
    public List<User> getIdcard(String idcard) {
        return userMapper.selectIdcard(idcard);
    }

    @Override
    public void addUser(User user) {
        userMapper.insertUser(user);
    }

    @Override
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }

    @Override
    public void deleteUser(int id) {
        userMapper.deleteUser(id);
    }

    @Override
    public void changePwd(User user) {
        userMapper.updateUser(user);
    }

    @Override
    public User selectOneUserByName(String username) {
        return userMapper.selectByName(username);
    }
}
